#include "led.h"
#include "uart4.h"
#include "beep.h"
#include "command.h"
extern void printf(const char *fmt, ...);
void delay_ms(unsigned int ms)
{
	int i,j;
	for(i = 0; i < ms;i++)
		for (j = 0; j < 1800; j++);
}

extern char  buffer[LEN];
int main()
{
	char *uart_str;
	command_t *cmd_p;
	hal_send_string("usart test code\n");
	hal_led_init();
	hal_beep_tim4_init();
	hal_uart4_init();  // 串口的初始化
	hal_send_string("usart init finished\n");
	while(1)
	{
		hal_send_string("usart command > ");
		uart_str = hal_recv_string(buffer);
		cmd_p = find_command(uart_str);
		if ( cmd_p != 0) {
			cmd_p->hal_gpio_write_p(cmd_p->gpios,
						cmd_p->pins,cmd_p->state);
		} else {
			hal_send_string("command not fount\n");
		}
	}
	return 0;
}
